#include "ThreadPool.hpp"

using namespace MyThreadPool;

void Push(std::string name)
{
    int cnt = 5;
    while(cnt--)
    {
        std::cout << "我是一个数据库传输任务, 我是线程：[" << name << "]";
        std::cout << std::endl;
        sleep(1);
    }
}

using task_t = std::function<void(std::string name)>;

int main()
{
    // std::shared_ptr<threadpool<task_t>>  tp = std::make_shared<threadpool<task_t>>();


    // ENABLE_CONSOLE_LOG_STRATEGY();

    // for (int i = 0; i < 10; i++)
    // {
    //     threadpool<task_t>::Getinstance()->Launch(); //线程
    // }
    threadpool<task_t>::Getinstance();
    //主线程
    // ENABLE_FILESYSTEM_LOG_STRATEGY();
    //如果我们想要传递任务呢?

    // int data = 0;
    int cnt = 5;

        threadpool<task_t>::Getinstance()->Equeue(Push);
        cnt--;
        sleep(1);



    // threadpool<task_t>::Getinstance()->stop();
    threadpool<task_t>::Getinstance()->Wait();

    return 0;
}